package com.zxf.android.mobilesafe.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;

public class RebootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent arg1) {
		System.out.println("---------------------");
		SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		boolean isProtected = sp.getBoolean("isProtected", false);
		if(isProtected) {
			String serialNumbe = sp.getString("serialNumbe", "");
			TelephonyManager teleManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
			String serialSIM = teleManager.getSimSerialNumber();
			if(!serialNumbe.equals(serialSIM)  ) {
				String safeNumber = sp.getString("safeNumber", "110");
				SmsManager sms = SmsManager.getDefault();
				sms.sendTextMessage(safeNumber, null, "SIM has changed !!!", null, null);
			}
		}

	}

}
